<template>
  <div>
    <div class="comment" v-if="Object.keys(commentInfo).length !== 0">
      <div class="info-header">
        <div class="header-title">用户评价</div>
        <div class="header-more">
          更多
          <i class="arrow-right"></i>
        </div>
      </div>
      <div class="info-user">
        <img :src="commentInfo.user.avatar" alt="">
        <span>{{commentInfo.user.uname}}</span>
      </div>
      <div class="info-detail">
        <p>{{commentInfo.content}}</p>
        <div class="info-other">
          <span class="date">{{commentInfo.created | showDate}}</span>
          <span>{{commentInfo.style}}</span>
        </div>
        <div class="info-pic">
          <img :src="item" 
               :key="index" 
               v-for="(item, index) in commentInfo.images" alt="">
        </div>
      </div>
    </div>
    <div class="comment" v-else>暂无用户评论</div>
  </div>
</template>

<script>
import {formatDate} from "common/utils";

export default {
  props: {
    commentInfo: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  filters: {
    showDate(value) {
      let date = new Date(value * 1000);
      return formatDate(date, "yyyy-MM-dd hh:mm");
    }
  }
}
</script>

<style scoped>
.comment {
  padding: 5px 10px;
  color: #333;
  border-bottom: 5px solid #f2f5f8;
}

.info-header {
  display: flex;
  justify-content: space-between;
  height: 50px;
  line-height: 50px;
  font-size: 15px;
  border-bottom: 1px solid rgba(0,0,0,.1);
}

.header-more {
  font-size: 13px;
  margin-right: 10px;
}

.header-more .arrow-right {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-top: 1px solid #999;
  border-right: 1px solid #999;
  transform: rotate(45deg);
  background-color: transparent;
}

.info-user {
  display: flex;
  align-items: center;
  padding: 10px 0 5px;
}

.info-user img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.info-user span {
  font-size: 15px;
  margin-left: 10px;
}

.info-detail {
  padding: 5px 5px 15px;
}

.info-detail p {
  line-height: 1.5;
  font-size: 14px;
  color: #777;
}

.info-detail .info-other {
  font-size: 12px;
  margin-top: 10px;
  color: #999;
}

.info-detail .info-other .date {
  margin-right: 8px;
}

.info-pic {
  margin-top: 10px;
}

.info-pic img {
  width: 70px;
  height: 70px;
  margin-right: 5px;
}
</style>